#include "session.h"


void Session::HandleDataCb(const u_char *data,const size_t len)
{
    u_int16_t msg_id=0;
    TypeTransfer<u_int16_t>::ByteArray2Type(msg_id,data+5);
    cout<<"msg_id:"<<msg_id<<endl;
    return;
}

void Session::HandleReadCb(const boost::system::error_code& error, size_t bytes_transferred)
{
    if(error)
    {
        cout<<"error:"<<error.message()<<endl;
        return;
    }
    cout<<"async read callback function"<<endl;
    cout<<bytes_transferred<<": ";
    for(size_t i = 0; i < bytes_transferred; i++)
        cout <<(int)frame.recv_data[i]<<" ";
    cout << endl;

    frame.ParseRecvData(bytes_transferred,shared_from_this());

    socket_.async_read_some(boost::asio::buffer(frame.recv_data),
                             boost::bind(&Session::HandleReadCb,
                                         shared_from_this(),
                                         boost::asio::placeholders::error,
                                         boost::asio::placeholders::bytes_transferred));
}
